package com.health.controller;

import com.health.common.PageBean;
import com.health.common.PageQueryDTO;
import com.health.common.Result;
import com.health.exception.CustomerException;
import com.health.pojo.CheckGroup;
import com.health.pojo.Setmeal;
import com.health.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhangzhen
 * @version 1.0
 * @date 2025/1/20 21:03
 */
@Slf4j
@RestController
@RequestMapping("/setmeal")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;
    @PostMapping("/findPage")
    public PageBean findPage(@RequestBody PageQueryDTO pageQueryDTO){
        PageBean page=setmealService.findPage(pageQueryDTO);
        return page;
    }

    @PostMapping("/add")
    public Result add(@RequestBody Setmeal setmeal, @RequestParam(value ="checkgroupIds") List<Integer> ids){
        try {
            setmealService.add(setmeal,ids);
        } catch (Exception e) {
            return Result.error("添加失败");
        }
        return Result.success();
    }
}